<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Schools Management System</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
<script type="text/javascript">
function del_confirm()
{
<?php
include_once '../Login/databaseconnection.php';

if(!loggedin())
{
	require_once '../index.php';
}
   
   else
   {

$Census_Number=$_POST['Census_Number'];
 
 if($Census_Number=="Select One")
	   {
		   $_SESSION['errorin']="Please select the censusnumber to delete!";
   
	   }  
   
  if($Census_Number!="Select One")
	   {
	     
	   ?>
	  $butt="";
var r=confirm("Are you sure to delete this?");
if (r==true)
  {
    $butt="Yes";
	<?php
 $result=mysql_query("SELECT * FROM school WHERE Census_Number='$Census_Number'");
 
  if(mysql_num_rows($result)==0)
   {

	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   else
   {
		  $del=mysql_query("DELETE FROM school WHERE Census_Number='$Census_Number'");
		  
	if($del)
  {
$_SESSION['error']="This record is successfully deleted!";
  }

  if(!$del)
  {
 $_SESSION['error']="Sorry unable to delete this record!";


  }
  }
  }
  ?>
 
}
if(r==false)
  {
    $butt="No";
  }
}
<?php
}
?>
</script>
</head>
<body>
 <?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';
}
else
{
	 /* $Census_Number="";
	 if(isset($_POST['Delete']))
	   { 
	   $Census_Number=$_POST['Census_Number'];
	    
	   }*/
	   
?>
<div id="wrap">

<div id="header"><table width="1239" border="0">
  <tr>
    <td width="866" height="119" rowspan="2"><h1 class="heaaderte"><font color="#996699" style="text-shadow:#969" size="+6">Schools Management System</font></h1></td>
    <td width="110" height="88">&nbsp;</td>
    <td width="161">&nbsp;</td>
    <td width="84">&nbsp;</td>
  </tr>
  <tr>
    <td height="21">&nbsp;</td>
    <td>
	<?Php
	//$First_Name=$_SESSION['First_Name'];
    //$_SESSION['Last_Name']=$Last_Name;
	  if(isset($_SESSION['First_Name']))
	  
{
      echo "Hi,". $_SESSION['First_Name']." ".$_SESSION['Last_Name'];
}
?></td>
    <td><a href="../Logout.php" class="logout">Logout</a></td>
  </tr>
  </table>
</div>

<div id="menu1_bg">
		<div id="menu1">
			
	
	
			<ul>
				<li><a href="../index.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Home</font></a></li>
				<li><a href="Schools.php" class="active"><font color="#CCCC66" style="text-shadow:#969" size="+1">Schools</font></a></li>
				<li><a href="../Teachers/teachers.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Teachers</font></a></li>
				<li><a href="../Lab/Labs.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Labs</font></a></li>
				<li><a href="../Resources/Resources.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resources</font></a></li>
                <li><a href="#"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resource Team</font></a></li>
                         <li><a href="../Programmes/Programmes.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Programmes</font></a></li>
                                  <li><a href="../Competition/Competition.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Competitions</font></a></li>
                 <li></li>
			</ul>
	</div>
</div>
<div class="left">
  
<div class="articles">
<form action="#" method="POST">
  <table width="620" border="0">
    <tr>
      <th height="29" colspan="4"  scope="row">
        <?php
      if(isset($_POST['Delete']))
{
	if($_SESSION['error']!=" ")
	{
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if($_SESSION['errorin']!=" ")
	{
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
}   
?>
</th>
</tr>
    <tr>
      <th width="87" height="41" align="left" scope="row">&nbsp;</th>
      <th width="154" align="left" scope="row"><label>School Census Number</label></th>
      <th width="18" align="left" scope="row">:-</th>
      <td width="343" colspan="2"><label for="select"></label>
        <select name="Census_Number" id="select">
		<?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$Census_Number.'">'.$Census_Number.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
      <?php
	  $CEN=mysql_query("SELECT DISTINCT(Census_Number) FROM school");
	  
  while($row=mysql_fetch_array($CEN))
  {
	  $cen_no=$row['Census_Number'];
	  echo '<option value="'.$cen_no.'">'.$cen_no.'</option>';
  }
	  ?>
     
      </select></td>
    </tr>
  </table>
  
  <a href="DelSch.php">Reset</a>
  <input name="Delete" align="middle" type="submit" value="Delete" onclick="del_confirm()"/>
  <br/>
  </form>
 <?php
 if(isset($_POST['Delete']))
{
  
if($Census_Number=="Select One")
	   {
		   $_SESSION['errorin']="Please select the censusnumber!";
    
	   }
	  if($Census_Number!="Select One")
	   {
	 
  
 echo'BASIC INFORMATION';
 echo '<br>';
  echo '<table width="582">';

while($row= mysql_fetch_array($result))
{
 echo'<tr>';
     echo '<th>';
	 echo "School ID";
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $row['School_Id'];
	echo '</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>';
	 echo 'School Name';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $row['Name'];
	echo '</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>';
	 echo 'School Address';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $row['Address'];
	echo '</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>';
	 echo 'Division';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $row['Division'];
	echo '</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'District'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['District'].'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'Province'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Province'].'</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'School Status'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Status'].'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'School Type'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Type'].'</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'Grade Range'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Grade_Range'].'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'Medium'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Medium'].'</td>';
    echo '</tr>';
	
	
	 echo'<tr>';
     echo '<th>'."Telephone Number".'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Tp_Number'].'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'Fax Number'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Fax_Number'].'</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'Email Address'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['E_Mail'].'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'Web Address'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Web_Address'].'</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'Account Number'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$row['Account_Number'].'</td>';
    echo '</tr>';
	
  }
  echo '</table>';
 } 

}
 ?>

  </div>
</div>

<div class="rightmenu"> 
      <h1>Schools</h1>
      <br/>
 <table width="220" border="0">
    <tr>
      <td height="41"><a href="AddSch.php">Add New School</a></td>
    </tr>
    <tr>
      <td height="41"><a href="SearchSch.php">Search a School's data</a></td>
    </tr>
    <tr>
      <td height="41"><a href="UpdateSch.php">Update a School's data</a></td>
    </tr>
    <tr>
      <td height="41"><a href="DelSch.php">Delete a School</a></td>
    </tr>
    <tr>
      <td height="41"><a href="Viewall.php">View All</a></td>
    </tr>
  </table>

</div>
 
 <div style="clear: both;"> </div>


<div id="footer">
  <table width="1217" height="50" border="0">
  <tr>
    <td width="903" height="46">Schools Managemrnt System &copy; 2012 </td>
    <td width="50"><strong><a href="#" class="active">Home</a><a href="#"></a></strong>|</td>
    <td width="91"><strong><a href="#">Contact us</a></strong>|</td>
    <td width="27"><a href="http//www.facebook.com"><img src="../images/facebook1.png" width="38" height="38"/></a></td>
    <td width="26"><a href="http//twitter.com"><img src="../images/twitter.png" width="38" height="38"/></a></td>
    <td width="26"><a href="http//www.google.lk"><img src="../images/google.png" width="38" height="38"/></a></td>
    <td width="64"><a href=""http="http"//www.yahoo.com""><img src="../images/yahoo.png" width="38" height="38"/></a></td>
  </tr>
</table>
</div>
</div>
<?php
	}
?>
</body>
</html>